﻿<h3>TestBootstrapChartPie</h3>
<Chart ChartType="ChartType.Pie" OnInitAsync="@OnInitLegendPosition" Height="300px" />
@code {
    private Random Randomer { get; } = new();

    private int PieDatasetCount = 1;

    private int PieDataCount = 5;

    private Task<ChartDataSource> OnInitLegendPosition()
    {
        var ds = new ChartDataSource();
        ds.Options.Title = "Pie chart";
        ds.Options.LegendPosition = ChartLegendPosition.Left;
        ds.Labels =Charts.Utility.Colors.Take(PieDataCount);
        for (var index = 0; index < PieDatasetCount; index++)
        {
            ds.Data.Add(new ChartDataset()
                {
                    Label = $"Set {index}",
                    Data = Enumerable.Range(1, PieDataCount).Select(i => Randomer.Next(20, 37)).Cast<object>()
                });
        }
        return Task.FromResult(ds);
    }
}
